package com.fary.beans.factory.config;

import com.fary.core.SpringException;
import com.fary.beans.TypeConverter;
import com.fary.beans.factory.BeanFactory;


import java.util.Set;


public interface AutowireCapableBeanFactory extends BeanFactory {

	/**
	 *
	 */
	int AUTOWIRE_NO = 0;

	/**
	 *
	 */
	int AUTOWIRE_BY_NAME = 1;

	/**
	 *
	 */
	int AUTOWIRE_BY_TYPE = 2;

	/**
	 *
	 */
	int AUTOWIRE_CONSTRUCTOR = 3;

	/**
	 *
	 */
	int AUTOWIRE_AUTODETECT = 4;

	/**
	 *
	 */
	String ORIGINAL_INSTANCE_SUFFIX = ".ORIGINAL";


	//-------------------------------------------------------------------------
	// Typical methods for creating and populating external bean instances
	//-------------------------------------------------------------------------

	/**
	 *
	 */
	<T> T createBean(Class<T> beanClass) throws SpringException;

	/**
	 *
	 */
	void autowireBean(Object existingBean) throws SpringException;

	/**
	 *
	 */
	Object configureBean(Object existingBean, String beanName) throws SpringException;


	//-------------------------------------------------------------------------
	// Specialized methods for fine-grained control over the bean lifecycle
	//-------------------------------------------------------------------------

	/**
	 *
	 */
	Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws SpringException;

	/**
	 *
	 */
	Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws SpringException;

	/**
	 *
	 */
	void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck) throws SpringException;

	/**
	 *
	 */
	void applyBeanPropertyValues(Object existingBean, String beanName) throws SpringException;

	/**
	 *
	 */
	Object initializeBean(Object existingBean, String beanName) throws SpringException;

	/**
	 *
	 */
	Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName) throws SpringException;

	/**
	 *
	 */
	Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName) throws SpringException;

	/**
	 *
	 */
	void destroyBean(Object existingBean);

	Object resolveDependency(DependencyDescriptor descriptor, String requestingBeanName, Set<String> autowiredBeanNames, TypeConverter typeConverter) throws SpringException;


}
